package es.uned.dia.james.helperUI;
import javax.swing.JTabbedPane;
import javax.swing.plaf.TabbedPaneUI;
import java.awt.Component;

public class TabbedPaneManager {
    JTabbedPane tabbedPane;
    Component[] tabs;
    
    public TabbedPaneManager(JTabbedPane tp) {
//        if(tp == null) throw new NullPointerException();
        tabs = tp.getComponents();
        tabbedPane = tp;
        tabbedPane.removeAll();
        tabbedPane.add(tabs[0]);
    }
    
    public boolean showTab(int index) {
        try {
            Component tabToShow = tabs[index];
            tabbedPane.removeAll();
            tabbedPane.add(tabToShow);            
        } catch (java.lang.Exception e) {
            return false;
        } 
        
        return true; 
    }    
}
